import myaxios from "./myAjax";
import mockAxios from "./mockAjax";
// const BASE_URL = "http://39.98.123.211"


//2. 登录 /api/user/passport/login
export const login = (phone, password) => {
    return myaxios({
        method: "post",
        url: "/user/passport/login",
        data: {
            phone, 
            password
        }
    })
}

// 3. 首页三级分类
// export const getBaseCategoryList = ()=> axios.get("/product/getBaseCategoryList")
export const getBaseCategoryList = () => {
    return myaxios({
        method: "GET",
        url: "/product/getBaseCategoryList"
    })
}


//4. 搜索商品
export const reqGetSearchList = (data) => {
    return myaxios({
        method: "POST",
        url: "/list",
        data,//放在请求体里参数,application/json
        // params:{a:1,b:2} a=1&b=2
    })
}

//5. 获取商品详情
export const reqGetGoodsDetial = (skuId) => {
    return myaxios({
        method: "GET",
        url: `/item/${skuId}`
    })
}

// 6. 获取购物车列表  /api/cart/cartList
export const reqGetCarlist = () => myaxios.get('/cart/cartList')


// 7. 添加到购物车(对已有物品进行数量改动)
export const reqAddToCart = (skuId, skuNum) => {
    return myaxios({
        method: "POST",
        url: `/cart/addToCart/${skuId}/${skuNum}`
    })
}

// 8. 切换商品选中状态 /api/cart/checkCart/{skuID}/{isChecked} get
export const reqCheckCart = (skuID,isChecked)=> myaxios.get(`/cart/checkCart/${skuID}/${isChecked}`)

// 9. 删除购物车商品 /api/cart/deleteCart/{skuId}  DELETE
export const reqDeleteCart =(skuId) => myaxios.delete(`/cart/deleteCart/${skuId}`)

// 10. 获取订单交易页信息 /api/order/auth/trade get
export const reqGetTrade = ()=> myaxios.get("/order/auth/trade")

// 11. 获取我的订单列表  /api/order/auth/{page}/{limit} get
export const reqGetMyorder = (page,limit)=> myaxios.get(`/order/auth/${page}/${limit}`)

// 12. 提交订单  /api/order/auth/submitOrder?tradeNo={tradeNo} post
export const submitOrder = ({
    tradeNo,
    consignee,
    consigneeTel,
    deliveryAddress,
    paymentWay,
    orderComment,
    orderDetailList,
})=>{
    return myaxios({
        method:"post",
        url:`/order/auth/submitOrder`,
        params:{
            tradeNo
        },
        data:{
            tradeNo,
            consignee,
            consigneeTel,
            deliveryAddress,
            paymentWay,
            orderComment,
            orderDetailList,
        }
    }) 
}

// 13. 获取订单支付二维码 /api/payment/weixin/createNative/{orderId} get
export const reqQRcode = (orderId)=> myaxios.get(`/payment/weixin/createNative/${orderId}`)

// 14. 查询支付订单状态 /api/payment/weixin/queryPayStatus/{orderId} get
export const reqQueryPayStatus = (orderId) => myaxios.get(`/payment/weixin/queryPayStatus/${orderId}`)


// 15. 发送手机验证码 /api/user/passport/sendCode/{ phone }  get
export const sendCode = (phone) => myaxios.get(`/user/passport/sendCode/${phone}`)

// 16. 注册用户 /api/user/passport/register  post 
export const reqRegister = (data) => {
    return myaxios({
        method: "POST",
        url: "/user/passport/register",
        data,
    })
}

// 17.退出登录
export const reqLogout = () => {
    return myaxios({
      method: "GET",
      url: "/user/passport/logout",
    });
  };

// 模拟的数据-----------------------------------------------------------------
  
//Home的轮播图数据
export const reqGetBanners = () => mockAxios.get('/getBanners')

//Floor（第一楼）的轮播图数据
// export const reqGetFloors = ()=> mockAxios.get('/getFloors')

//Floor的所有数据
export const reqGetFloors = () => mockAxios.get('/getFloors1')